package com.buding.fx.controller.codeformat;

import com.buding.fx.view.CodeFormatStart;
import com.jfoenix.controls.JFXButton;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TableView;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.management.BufferPoolMXBean;
import java.net.URL;
import java.util.ResourceBundle;

/**
 * @Author: mingdongwei
 * @Date: 2024-05-02
 * @Description:
 * @Version: 1.0.0
 */
public class CodeFormatJavaController implements Initializable {
    private Logger logger = LoggerFactory.getLogger(CodeFormatJavaController.class);
    @FXML
    private ScrollPane javaPane;

    private Stage stage;


    public Stage getStage() {
        return stage;
    }

    public void setStage(Stage stage) {
        logger.info("java controller set stage");
        this.stage = stage;
    }


    @Override
    public void initialize(URL location, ResourceBundle resources) {
        logger.info("java controller init: {}","001");
        GridPane gridPane = new GridPane();

        VBox left = new VBox();
        JFXButton jfxButton = new JFXButton("表表设置");
        left.getChildren().add(jfxButton);

        Pane pane = new Pane();
        VBox vBox = new VBox();
        FlowPane flowPane = new FlowPane();

        Button button = new Button("增加表头");
        Button  button1 = new Button("删除表头");
        Button button2 = new Button("文件导入");
        Button button3 = new Button("JSON生成");
        flowPane.getChildren().addAll(button,button1,button2,button3);
        TableView tableView = new TableView();
        vBox.getChildren().addAll(flowPane,tableView);
        pane.getChildren().add(vBox);

        gridPane.add(left,0,0);
        gridPane.add(pane,1,0);
        javaPane.setContent(gridPane);

    }

    public void resize(){
        Scene scene = stage.getScene();
        double rootweight = scene.getWidth();
        double rootHeight = scene.getHeight();
        javaPane.setMaxWidth(rootweight);
        javaPane.setMaxHeight(rootHeight);
        logger.info("java controller resize  weight: {}, height: {}",rootweight,rootHeight);
    }
}
